<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>axios测试get, post请求</title>
    <script src="../../js/axios.min.js"></script>
</head>
<body>
<button onclick="get()">get请求</button>
<button onclick="err()">err请求</button>
<button onclick="post()">post请求</button>
</body>
<script>

    function get() {
        let url = 'http://localhost/json/view4?ids=1,2';
        axios.get(url).then(function (responseData) {
            console.log(responseData);
        });
    }

    function err() {
        let url = 'http://localhost/json1111/view4?ids=1,2';
        axios.get(url).then(function (responseData) {
            console.log(responseData);
        }, function (err) {
            console.log(err, 1);
        });
    }

    function post() {
        let url = 'http://localhost/json/view4';
        let params = {
            ids: [1, 2]
        };
        //axios会自动将参数转换为json形式.
        axios.post(url, params).then(function (responseData) {
            console.log(responseData);
        }, function (err) {
            console.log(err);
        });
    }

</script>
</html>